import dateOptions from "@/utils/date"; //引入date的渲染
import {findPage,addIndent,insertCountgoods} from '@/api/addIndent'//引入axios的请求
let market = {
    // name: "index",
    data() {
        return {
            formIndentData: {},//新增表单信息
            dialogVisibleTwo: false,
            searchData: {
                currentPage: 1,//当前页
                pageSize: 5,//每页显示条数
            },
            dateOptions,
            tableData: [],
            formCountIndentData:{
                batchIds:[],
            }

        }


    },
    created() {//回调函数
        // console.log("asd1")
        //查询
        // this.searchPage();
        // this.searchAllIndent();


    },
    methods: {
        /**
         * 查询所有
         */
        async searchPage() {
            //执行查询
            let response = await findPage(this.searchData);
            console.log(response.data);
            this.total = response.total;//总行数复制
            this.tableData = response.data;//数据信息赋值

        }, //点击下一页 发生改变
        currentPageChange(page) {
            this.searchData.currentPage = page;//当前页赋值
            this.searchPage();//刷新页面
        },
        reset() {
            this.searchData.currentPage = 1;
            this.searchData.pageSize = 5;
            this.searchData.goodsName = '';
            this.searchPage();
        },
        findIndentBylike() {
            this.searchPage();
        },
        open() {
            this.$message('添加商品成功！');
        },
        //checkbox勾选改变
        selectChange(val) {

            //勾选二个的时候修改失效  删除有效
            this.formCountIndentData.batchIds = val.map(item => item.goodsId);
            // console.log(this.batchIds);
        },
        //添加订单信息
        async insertIndent() {
            let resepose = await addIndent(this.formIndentData);
            this.formCountIndentData.id=resepose;
            console.log(this.formCountIndentData.id );
            this.addCountgoods();

        },
        //添加订单商品信息
        async addCountgoods() {
            await insertCountgoods(this.batchIds);
        }
    }

}

export default market;